<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/4/6
  Time: 10:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <script>
        function checkUsername(){
            return /^\w{6,12}$/.test(document.getElementById("username").value);
        }
        function checkPassword(){
            return /^\w{6,12}$/.test(document.getElementById("password").value);
        }

        window.onload = function (){
            document.getElementById("form").onsubmit = function (){
                if (checkPassword() && checkUsername()){
                    return true;
                }else {
                    alert("账号密码不少于6位");
                    return false;
                }
            }
        }

    </script>
</head>
<body>
    <form action="success.jsp" method="post" id="form">
        <div>
            账号：
            <input type="text" name="username" id="username">
        </div>
        <div>
            密码：
            <input type="password" name="password" id="password">
        </div>
        <div>
            <input type="submit" value="登录">
            <input type="reset" value="重置">
        </div>
        <%
            String mesg = (String) request.getAttribute("mesg");
            if (mesg != null){
                out.write(mesg);
            }
        %>
    </form>
</body>
</html>
